import {defineConfig} from 'vite'
import vue from '@vitejs/plugin-vue'
import path from 'path'
import WindiCSS from 'vite-plugin-windicss'

// https://vitejs.dev/config/
export default defineConfig({
    plugins: [vue(), WindiCSS()],
    resolve: {
        // 使用别名
        alias: {
            '@': path.resolve(__dirname, './src')
        }
    },
    server: {
        open: true,
        proxy: {
            // 选项写法
            '/api': {
                target: 'http://127.0.0.1:7295',
                changeOrigin: true,
                rewrite: (path) => path.replace(/^\/api/, '')
            },
            '/ipaddr': {
                target: 'https://apis.map.qq.com/ws/location/v1/ip?key=W27BZ-EMOCU-JU5VO-4P5OB-BJDVE-N7B2J',
                changeOrigin: true,
                rewrite: (path) => path.replace(/^\/ipaddr/, '')
            }
        }
    }
})
